#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;

struct TStudent {
    string Name;
    string LastName;
    double AverageMark;
    int RoomNumber;

    TStudent()
        : AverageMark(0.0)
        , RoomNumber(-1) {
    }

    TStudent(string name, string lastName, double averageMark, int roomNumber)
        : Name(name)
        , LastName(lastName)
        , AverageMark(averageMark)
        , RoomNumber(roomNumber) {
    }
};

typedef int (*TCompareFuncPtr) (const void *, const void *);

int Cmp(const void *l, const void *r) {
    const TStudent *pl = *(const TStudent**)l;
    const TStudent *pr = *(const TStudent**)r;
    if (pl->Name == pr->Name)
        return 0;
    if (pl->Name < pr->Name)
        return -1;
    return 1;
}

static void LoadDB(string fileName, vector<TStudent> &students) {
    ifstream ifile(fileName.c_str());
    while (!ifile.eof()) {
        TStudent s;
        ifile >> s.Name >> s.LastName >> s.AverageMark >> s.RoomNumber;
        students.push_back(s);
    }
    ifile.close();
}

static void PrintDB(const vector<TStudent> &students) {
    for (vector<TStudent>::const_iterator iter = students.begin(), end = students.end(); iter != end; ++iter) {
        cout << "\"" << iter->Name          << "\"\t"
             << "\"" << iter->LastName      << "\"\t"
             << iter->AverageMark   << "\t"
             << iter->RoomNumber
             << endl;
    }
}

int main() {
    vector<TStudent> students;
    LoadDB("db.txt", students);
    PrintDB(students);
    return 0;
}
